package com.hean.activity;

import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class SmsActivity extends Activity {
	private EditText phoneText;
	private EditText smsText;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        phoneText =(EditText) this.findViewById(R.id.phonenumber);
        smsText=(EditText) this.findViewById(R.id.smscontent);
        Button send=(Button) this.findViewById(R.id.send);
        send.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				String phonenumber=phoneText.getText().toString();
				String smsContent=smsText.getText().toString();
				SmsManager smsManager=SmsManager.getDefault();
				if(smsContent.length()>70){
					List<String> smses=smsManager.divideMessage(smsContent);
					for (String sms : smses) {
						smsManager.sendTextMessage(phonenumber, null, sms, null, null);
					}
				}else{
					smsManager.sendTextMessage(phonenumber, null, smsContent, null, null);
				}
				Toast.makeText(SmsActivity.this, "发送成功", Toast.LENGTH_SHORT).show();
//				Toast.makeText(context, resId, duration).show()//resId发送成功
			}
		});
    }
}